﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Epitech.Krisk.Xna.ScreenManagerLib.ScreenManager;
using Epitech.Krisk.Xna.UI.Game.InGame.Gameplay;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace Epitech.Krisk.Xna.UI.Game.InGame
{
    public class ClickableCard : AGameObject
    {
        public Texture2D Card { get; set; }
        public Rectangle Resize { get; set; }
        public Color SelectedColor { get; set; }
        public bool IsSelected { get; protected set; }
        public TerritoryCard TerritoryCard { get; set; }

        private Color _color;

        public ClickableCard()
        {
            IsSelected = false;
            _color = Color.White;
        }

        public override void Draw(GameTime gameTime)
        {
            SpriteBatch.Begin();
            SpriteBatch.Draw(Card, Resize, _color);
            SpriteBatch.End();
        }

        public override void HandleInput(InputState input)
        {
            PlayerIndex tmp;

            if (input.IsNewMouseButtonDown(MouseButton.Left)
                || input.IsNewButtonPress(Buttons.A, null, out tmp))
            {
                Vector2 mousepos = input.MousePosition();
                if (Resize.Contains((int)mousepos.X, (int)mousepos.Y))
                {
                    _color = IsSelected ? Color.White : SelectedColor;
                    IsSelected = !IsSelected;
                }
            }
        }
    }
}
